<!--
 * @Author: wangshuixin 2412658453@qq.com
 * @Date: 2024-11-11 09:56:04
 * @LastEditors: wangshuixin 2412658453@qq.com
 * @LastEditTime: 2025-01-22 10:15:28
 * @FilePath: \sr_system_manager_ui\src\components\ResultsManagement\Patent\detail.vue
 * @Description: 专利/软著管理详情页
-->
<script setup lang="ts">
import { onMounted, ref, watch } from 'vue'
import { ElMessage } from 'element-plus'
import StatusBar from '@/components/StatusBar/index'
import ApplicantInfo from '@/components/ApplicantInfo/index'
import DelConfirmModal from '@/components/DelConfirmModal'
import { AuditLogResultColorMap, AuditLogResultMap } from '@/utils/constText'
import { dictEnum } from '@/utils/constEnum'
import useUserStore from '@/store/modules/user'
import { getPatentDetailApi, updatePatentDetailApi, createPatentDetailApi } from '@/api/resultsManagement/patentApi'
import { auditLogApi, approveResultsManagementApi, deleteResultsManagementApi, appraiseStandardApi, getResearchScoreApi } from '@/api/resultsManagement/index'
import type { SheetInfoComponent, SelectComponentDataDTO } from '@/types/component'
import type { PatentListResp, AppraiseStandardDTO } from '@/types/resultsManagement'
import type { AppStateChangeRespDTO, AttachmentFileInfoDTO } from '@/types/index'
import { Plus } from '@element-plus/icons-vue'
import { fileToPdfReq } from '@/api/common'

const props = defineProps({
  /* 模块类型：college 学院成果管理；office 科研处成果管理；mine 我的成果； */
  moduleType: {
    type: String as PropType<'college' | 'office' | 'mine'>,
    default: 'college',
  },
})

// 当前实例
const { proxy } = getCurrentInstance()

const dict = proxy.useDict(dictEnum.reviewOpinion, dictEnum.patentCategory)

const route = useRoute()
const router = useRouter()

const sheetComponents = ref<SheetInfoComponent[]>([{
    title: '发明人',
    type: 3,
    key: 'accountName',
    labelWidth: computed(() => { return route.query.id && route.query.mode !== 'edit' ? '130px' : '120px' }),
    width: computed(() => { return route.query.id && route.query.mode !== 'edit' ? 'calc(50% - 130px)' : 'calc(50% - 120px)' }),
    config: {
      rules: [
        { required: true, message: '发明人不能为空'},
      ],
      editStyle: computed(() => { return route.query.id && route.query.mode !== 'edit' ? {} : { marginTop: '-16px' } }),
    }
  },
  {
    title: '专利/软著名称',
    type: 0,
    key: 'name',
    labelWidth: computed(() => { return route.query.id && route.query.mode !== 'edit' ? '130px' : '120px' }),
    width: computed(() => { return route.query.id && route.query.mode !== 'edit' ? 'calc(50% - 130px)' : 'calc(50% - 120px)' }),
    placeholder: '请输入',
    config: {
      rules: [
        { required: true, message: '专利/软著名称不能为空'},
      ],
      maxLength: 50,
      showWordLimit: true,
    }
  },
  {
    title: '专利号/登记号',
    type: 0,
    key: 'patentNumber',
    labelWidth: computed(() => { return route.query.id && route.query.mode !== 'edit' ? '130px' : '120px' }),
    width: computed(() => { return route.query.id && route.query.mode !== 'edit' ? 'calc(50% - 130px)' : 'calc(50% - 120px)' }),
    placeholder: '请输入',
    config: {
      rules: [
        { required: true, message: '专利号/登记号不能为空'},
      ],
      maxLength: 50,
      showWordLimit: true,
    }
  },
  {
    title: '授权公告日',
    type: 2,
    key: 'businessDate',
    labelWidth: computed(() => { return route.query.id && route.query.mode !== 'edit' ? '130px' : '120px' }),
    width: computed(() => { return route.query.id && route.query.mode !== 'edit' ? 'calc(50% - 130px)' : 'calc(50% - 120px)' }),
    placeholder: '请选择日期',
    config: {
      rules: [
        { required: true, message: '授权公告日不能为空'},
      ]
    }
  },
  {
    title: '专利/软著类别', // 需要获取后台数据
    type: 1,
    key: 'patentType',
    labelWidth: computed(() => { return route.query.id && route.query.mode !== 'edit' ? '130px' : '120px' }),
    width: computed(() => { return route.query.id && route.query.mode !== 'edit' ? 'calc(50% - 130px)' : 'calc(50% - 120px)' }),
    placeholder: '请选择',
    config: {
      options: computed<SelectComponentDataDTO[]>(() => { return dict[dictEnum.patentCategory] }),
      rules: [
        { required: true, message: '专利/软著类别不能为空'},
      ],
    }
  },
  {
    title: '专利权人',
    type: 6,
    key: 'patentee',  
    labelWidth: computed(() => { return route.query.id && route.query.mode !== 'edit' ? '130px' : '120px' }),
    width: computed(() => { return route.query.id && route.query.mode !== 'edit' ? 'calc(50% - 130px)' : 'calc(50% - 120px)' }),
    cValue: ['南昌交通学院'],
    config: {
      rules: [
        { required: true, message: '专利权人不能为空'},
      ]
    }
  },
  {
    title: '项目成果',
    type: 4,
    key: 'outcomeFlag',
    cValue: false,
    labelWidth: computed(() => { return route.query.id && route.query.mode !== 'edit' ? '130px' : '120px' }),
    width: computed(() => { return route.query.id && route.query.mode !== 'edit' ? 'calc(50% - 130px)' : 'calc(50% - 120px)' }),
    config: {
      options: [
        {title: '属于项目成果', value: true},
        {title: '不属于项目成果', value: false},
      ],
      rules: [
        { required: true, message: '项目成果不能为空'},
      ]
    }
  },
  {
    title: '统计年度',
    type: 3,
    key: 'statisticalYear',
    labelWidth: computed(() => { return route.query.id && route.query.mode !== 'edit' ? '130px' : '120px' }),
    width: computed(() => { return route.query.id && route.query.mode !== 'edit' ? 'calc(50% - 130px)' : 'calc(50% - 120px)' }),
    placeholder: '请选择年份',
    config: {
      rules: [
        { required: true, message: '统计年度不能为空'},
      ],
      type: 'year',
      valueFormat: 'YYYY'
    }
  },
  {
    title: '科研分',
    type: 4,
    key: 'researchScoreFlag',
    cValue: false,
    labelWidth: computed(() => { return route.query.id && route.query.mode !== 'edit' ? '130px' : '120px' }),
    width: computed(() => { return route.query.id && route.query.mode !== 'edit' ? 'calc(100% - 130px)' : 'calc(50% - 120px)' }),
    config: {
      options: [
        {title: '属于科研分认定范畴', value: true},
        {title: '不属于科研分认定范畴', value: false},
      ],
      rules: [
        { required: true, message: '科研分认定范畴类型不能为空'},
      ],
    }
  },
  {
    title: '',
    type: 99,
    key: 'assessmentMethodId',
    depended: 'researchScoreFlag',
    hidden: true,
    placeholder: '请选择',
    config: {
      list: [{
        title: '计分类别',
        type: 1,
        key: 'scoringCategoryId',
        depended: 'researchScoreFlag',
        placeholder: '请选择计分类别',
        config: {
          options: [],
          rules: [
            { required: true, message: '计分类别不能为空' },
          ]
        }
      }, {
        title: '量化指标',
        type: 1,
        key: 'methodCalculationId',
        depended: 'scoringCategoryId',
        placeholder: '请选择量化指标',
        config: {
          options: [],
          rules: [
            { required: true, message: '量化指标不能为空' },
          ]
        }
      }, {
        title: '金额',
        type: -1,
        key: 'amount',
        depended: 'methodCalculationId',
        placeholder: ' 请输入',
        config: {
          rules: [
            { required: true, message: '金额不能为空' },
          ],
          suffix: '万元',
          controls: false,
          min: 0,
          max: 99999999
        }
      }, {
        title: '科研分',
        type: 3,
        key: 'researchScore',
        depended: 'methodCalculationId',
        config: {
          rules: [
            { required: true, message: '科研分不能为空' },
          ],
          suffix: '分',
          min: 0,
          max: 99999999
        }
      }]
    }
  },
  {
    title: '授权/登记证书',
    type: 5,
    key: 'warrantyAuthorityFileList',
    labelWidth: computed(() => { return route.query.id && route.query.mode !== 'edit' ? '130px' : '120px' }),
    width: computed(() => { return route.query.id && route.query.mode !== 'edit' ? 'calc(100% - 130px)' : 'calc(100% - 120px)' }),
    placeholder: '请上传',
    config: {
      rules: [
        { required: true, message: '授权/登记证书不能为空'},
      ],
    }
  },
  {
    title: '其他附件',
    type: 5,
    labelWidth: computed(() => { return route.query.id && route.query.mode !== 'edit' ? '130px' : '120px' }),
    width: computed(() => { return route.query.id && route.query.mode !== 'edit' ? 'calc(100% - 130px)' : 'calc(100% - 120px)' }),
    key: 'fileList',
    placeholder: '请上传',
    config: {
      rules: [
        { required: false, message: '其他附件不能为空'},
      ],
    }
  },
  {
    title: '',
    type: 6,
    labelWidth: computed(() => { return route.query.id && route.query.mode !== 'edit' ? '130px' : '120px' }),
    width: computed(() => { return route.query.id && route.query.mode !== 'edit' ? 'calc(100% - 130px)' : 'calc(100% - 120px)' }),
    key: 'fileTip',
    hidden: route.query.mode !== 'edit' && route.query.id
  },
  {
    title: '备注',
    type: 0,
    labelWidth: computed(() => { return route.query.id && route.query.mode !== 'edit' ? '130px' : '120px' }),
    width: computed(() => { return route.query.id && route.query.mode !== 'edit' ? 'calc(100% - 130px)' : 'calc(100% - 120px)' }),
    key: 'remark',
    placeholder: '请输入...',
    config: {
      type: 'textarea',
      maxLength: 500,
      showWordLimit: true,
    }
  },
])

// 审核记录 >> 表头
const columns = ref([
  {
    title: '序号',
    width: 46,
    dataIndex: 'index',
    slotName: 'index',
  },
  {
    title: '操作时间',
    width: 220,
    dataIndex: 'createdTime',
    slotName: 'createdTime',
    tooltip: true,
  },
  {
    title: '节点',
    width: 160,
    dataIndex: 'typeName',
    slotName: 'typeName',
    tooltip: true,
  },
  {
    title: '操作人',
    width: 160,
    dataIndex: 'createdByName',
    slotName: 'createdByName',
    tooltip: true,
  },
  {
    title: '操作结果',
    width: 160,
    dataIndex: 'status',
    slotName: 'status',
    tooltip: true,
  },
  {
    title: '审核',
    minWidth: 354,
    dataIndex: 'approve',
    slotName: 'approve',
  }
])

// 审核意见
const approvalComponents = ref([
  {
    title: '审核意见',
    type: 0,
    labelWidth: '130px',
    width: 'calc(100% - 130px)',
    key: 'description',
    placeholder: '请输入...',
    config: {
      rules: [
        { required: true, message: '审核意见不能为空'},
      ],
      type: 'textarea',
      maxLength: 500,
      showWordLimit: true,
      sheetInfoRowMarginTop: '0px',
      options: computed(() => dict[dictEnum.reviewOpinion] || [])
    }
  },
  {
    title: '相关附件',
    type: 5,
    key: 'fileList',
    labelWidth: '130px',
    width: 'calc(100% - 130px)',
    placeholder: '请上传',
    config: {
      rules: [
        { required: false, message: '附件不能为空'},
      ]
    }
  },
])

// 文件上传地址
const uploadFileUrl = ref(import.meta.env.VITE_APP_BASE_API + "/base/api/attachment/upload"); // 上传文件服务器地址
// 成果详情id
const detailId = ref()
// 用户信息
const userStore = useUserStore()
// 审核状态
const status = ref(-1)
// 列表数据
const dataList = ref([])
const ResultsInfoRef = ref()
const ApprovalRef = ref()
// 显示删除弹框
const showDeleteDetail = ref(false)
// 显示取消保存弹框
const showCancelSave = ref(false)
// 显示提交弹框
const showSubmitSave = ref(false)
// 显示审核不通过弹框
const showDisApprove = ref(false)
// 显示审核通过弹框
const showApprove = ref(false)
// 全量的量化指标
const appraiseStandardList = ref<AppraiseStandardDTO[]>([])
// 学院、部
const departmentName = ref()
// 工号
const applyCode = ref()
// 姓名
const applyName = ref()
// 专利权人
const patenteeInput = ref()
// 显示 添加其他企业 按钮
const showPatenteeAddBtn = ref(true)
// 参数
const parameters = computed(() => {
  return {
    ...ResultsInfoRef.value.params,
    achvId: route.query.id,
    // 科研分 - 考核办法ID
    assessmentMethodId: ResultsInfoRef.value && ResultsInfoRef.value.params && appraiseStandardList.value.length > 0 && ResultsInfoRef.value.params['methodCalculationId'] && appraiseStandardList.value.filter(item => item.id === ResultsInfoRef.value.params['methodCalculationId']).length > 0 ? appraiseStandardList.value.filter(item => item.id === ResultsInfoRef.value.params['methodCalculationId'])[0]['assessmentMethodId'] : undefined,
    // 授权证书
    warrantyAuthorityFile: ResultsInfoRef.value && ResultsInfoRef.value.params && ResultsInfoRef.value.params['warrantyAuthorityFileList'] ? ResultsInfoRef.value.params['warrantyAuthorityFileList'].map((file: AttachmentFileInfoDTO) => {
      return file.id
    }) : undefined,
    // 其他附件
    fileIds: ResultsInfoRef.value && ResultsInfoRef.value.params && ResultsInfoRef.value.params['fileList'] ? ResultsInfoRef.value.params['fileList'].map((file: AttachmentFileInfoDTO) => {
      return file.id
    }) : undefined,
  }
})

// 关闭当前页签
const closeCurrentTab = () => {
  proxy.$tab.closePage()
}

// 获取专利软著详情
const { runAsync: getDetail, loading } = useRequest(getPatentDetailApi, {
  // false 为自动执行
  manual: true,
  // 请求成功
  onSuccess: (response: PatentListResp) => {
    if (response) {
      status.value = response.status!
      departmentName.value = response.departmentName
      applyName.value = response.accountName
      applyCode.value = response.accountCode
      if (status.value === 5 && appraiseStandardList.value.filter(item => item.id === response['methodCalculationId']).length === 0) { // 审核状态：已登记
        const appraiseStandard = {
          ...response,
          typeName: response.typeName, // 计分类别
          title: response.quanIndicators,
          value: response.methodCalculationId,
          id: response.methodCalculationId,
          typeId: response.methodCalculationId,
          type: response.methodType,
          typeReal: response.methodTypeReal,
        }
        appraiseStandardList.value = [...appraiseStandardList.value, appraiseStandard]
      }
      const researchScoreOption = appraiseStandardList.value.filter(item => item.id === response['methodCalculationId']).length > 0 ? appraiseStandardList.value.filter(item => item.id === response['methodCalculationId'])[0] : undefined
      sheetComponents.value.forEach((component: SheetInfoComponent) => {
        if (response[component.key]) {
          //给表单赋值
          if (component.key === 'fileList' || component.key === 'warrantyAuthorityFileList') {
            component.cValue = response[component.key].map((file) => {
              return {
                ...file,
                uid: file.fileId,
              }
            })
          } else {
            component.cValue = response[component.key]
          }
        }
        // 混合组件赋值
        if (component.type === 99 && component.config && component.config.list) {
          component.config.list.forEach((subComponent: SheetInfoComponent) => {
            // 科研分的考核指标更新，此处兼容 计分类别
            if (subComponent.key === 'scoringCategoryId' && subComponent.config) {
              // 用于存储唯一标题的对象
              const uniqueTitles = []
              subComponent.config.options = appraiseStandardList.value.map((item: AppraiseStandardDTO) => {
                return {
                  title: item.typeName,
                  value: item.typeId,
                }
              }).filter(item => {
                // 状态：已登记；特殊处理 计分类别
                if (status.value === 5 && item.value === response['methodCalculationId']) { // 说明是更新后的考核指标，所以需要将已登记的考核指标回显到 考核指标 数组
                  return true
                }
                // 如果uniqueTitles中还没有这个title，则添加它并返回true
                if (!uniqueTitles[item.title]) {
                  uniqueTitles[item.title] = true
                  return true
                }
                // 如果已经有了这个title，则返回false
                return false
              })
            }
            // 特殊处理 计分类别，由于methodCalculationId依赖 计分类别
            if (subComponent.key === 'scoringCategoryId' && response['methodCalculationId'] && appraiseStandardList.value.filter(item => item.id === response['methodCalculationId']).length > 0) {
              subComponent.cValue = appraiseStandardList.value.filter(item => item.id === response['methodCalculationId'])[0]['typeId']
            } else {
              // 金额和科研分组件的判定，type === 5 则手输科研分，否则根据typeReal === 2| 3 手输金额，1则自动带出分数
              if (researchScoreOption) {
                if (subComponent.key === 'amount') { // 金额 amount
                  if (researchScoreOption.type === 5) {
                    subComponent.hidden = true
                  } else {
                    if (researchScoreOption.typeReal === 2 || researchScoreOption.typeReal === 3) {
                      subComponent.type = -1
                      subComponent.hidden = false
                      if (subComponent.config && subComponent.config.rules.length > 0) {
                        subComponent.config.rules[0].required = true
                      }
                    } else {
                      subComponent.hidden = true
                      if (subComponent.config && subComponent.config.rules.length > 0) {
                        subComponent.config.rules[0].required = false
                      }
                    }
                    if (subComponent.config) {
                      subComponent.config.suffix = researchScoreOption.unitEnum === 1 ? '元' : '万元'
                      subComponent.config.precision = researchScoreOption.unitEnum === 1 ? 2 : 6
                    } else {
                      subComponent.config = {}
                      subComponent.config.suffix = researchScoreOption.unitEnum === 1 ? '元' : '万元'
                      subComponent.config.precision = researchScoreOption.unitEnum === 1 ? 2 : 6
                    }
                  }
                } else if (subComponent.key === 'researchScore') { // 科研分 researchScore
                  if (researchScoreOption.type === 5) {
                    subComponent.type = -1
                    if (subComponent.config) {
                      subComponent.config.controls = false
                    } else {
                      subComponent.config = {}
                      subComponent.config.controls = false
                    }
                    if (subComponent.config && subComponent.config.rules.length > 0) {
                      subComponent.config.rules[0].required = true
                    }
                  } else {
                    subComponent.type = 3
                    if (subComponent.config && subComponent.config.rules.length > 0) {
                      subComponent.config.rules[0].required = false
                    }
                  }
                }
              }
              subComponent.cValue = response[subComponent.key]
            }
          })
        }
      })
    }
  },
  // 请求失败
  onError: () => {
  },
})

// 查询审核日志
const { runAsync: getAuditLog, loading: logLoading } = useRequest(auditLogApi, {
  // false 为自动执行
  manual: true,
  // 请求成功
  onSuccess: (response: any) => {
    dataList.value = response
  },
  // 请求失败
  onError: () => {
  },
})

/* 创建 */
const { runAsync: createDetail, loading: createLoading } = useRequest(createPatentDetailApi, {
  // false 为自动执行
  manual: true,
  // 请求成功
  onSuccess: (response: AppStateChangeRespDTO, _params) => {
    if (response.isSuccess) {
      detailId.value = response.id
      closeCurrentTab()
      setTimeout(() => {
        router.push({
          name: 'mine-patent-detail',
          query: { id: response.id, mode: !_params[0].isSubmit ? 'edit' : 'preview' }
        })
        if (!_params[0].isSubmit) {
          ElMessage.success('保存成功')
        } else {
          setTimeout(() => {
            ElMessage.success('提交成功')
          }, 500)
        }
      }, 300)
    }
  },
  // 请求失败
  onError: () => {
  },
})

/* 更新详情 */
const { runAsync: updateDetail, loading: updateLoading } = useRequest(updatePatentDetailApi, {
  // false 为自动执行
  manual: true,
  // 请求成功
  onSuccess: (response: AppStateChangeRespDTO, _params) => {
    if (response.isSuccess) {
      if (!_params[0].isSubmit) {
        ElMessage.success('保存成功')
      }
      if (status.value === 3 || status.value === 4) {
        getDetail({ id: route.query.id })
      }
    }
  },
  // 请求失败
  onError: () => {
  },
})

/* 删除详情 */
const { run: deleteDetail, loading: deleteLoading } = useRequest(deleteResultsManagementApi, {
  // false 为自动执行
  manual: true,
  // 请求成功
  onSuccess: (response: AppStateChangeRespDTO) => {
    if (response.isSuccess) {
      ElMessage.success('删除成功')
      closeCurrentTab()
    }
  },
  // 请求失败
  onError: () => {
  },
})

/* 获取考核量化指标 */
const { runAsync: getAppraiseStandardList } = useRequest(appraiseStandardApi, {
  // false 为自动执行
  manual: true,
  // 请求成功
  onSuccess: (response: AppraiseStandardDTO[]) => {
    if (response && response.length) {
      appraiseStandardList.value = response.map((item: AppraiseStandardDTO) => {
        return {
          ...item,
          title: item.name,
          value: item.id,
        }
      })
      sheetComponents.value.forEach((component: SheetInfoComponent) => {
        if (component.key === 'assessmentMethodId' && component.config && component.config.list) {
          component.config.list.forEach((subComponent: SheetInfoComponent) => {
            // 计分类别 typeName
            if (subComponent.key === 'scoringCategoryId' && subComponent.config) {
              // 用于存储唯一标题的对象
              const uniqueTitles = {}
              subComponent.config.options = response.map((item: AppraiseStandardDTO) => {
                return {
                  title: item.typeName,
                  value: item.typeId,
                }
              }).filter(item => {
                // 如果uniqueTitles中还没有这个title，则添加它并返回true
                if (!uniqueTitles[item.title]) {
                  uniqueTitles[item.title] = true
                  return true
                }
                // 如果已经有了这个title，则返回false
                return false
              })
            }
          })
        }
      })
    }
  },
  // 请求失败
  onError: () => {
  },
})

/* 审核 */
const { runAsync: approveDetail, loading: approveLoading } = useRequest(approveResultsManagementApi, {
  // false 为自动执行
  manual: true,
  // 请求成功
  onSuccess: (response: AppStateChangeRespDTO, params) => {
    if (response.isSuccess) {
      if (params[0].status === 1) {
        ElMessage.success('提交成功')
      } else if (params[0].status === 2 || params[0].status === 5) {
        ElMessage.success('审核通过')
      } else if (params[0].status === 3 || params[0].status === 4) {
        ElMessage.success('审核不通过')
      }
      if (!route.query.id || (route.query.id && route.query.mode === 'edit')) {
        // 修改参数
        const newQuery = {
          ...route.query,
          mode: 'preview'
        }
        router.replace({query: newQuery})
        sheetComponents.value.forEach((component: SheetInfoComponent) => {
          // 模块为我的成果，且mode=edit时，进入编辑模式，否则进入预览模式（没有详情id，说明是新建）
          if (component.config) {
            component.config.readonly = true
          } else {
            component.config = {}
            component.config.readonly = true
          }
          if (component.type === 99 && component.config && component.config.list) {
            component.config.list.forEach((subComponent: SheetInfoComponent) => {
              if (subComponent.config) {
                subComponent.config.readonly = true
              } else {
                subComponent.config = {}
                subComponent.config.readonly = true
              }
            })
          }
        })
      }
      getAuditLog({ logId: route.query.id as string })
      getDetail({ id: route.query.id })
    }
  },
  // 请求失败
  onError: () => {
  },
})

/* 查询科研分 */
const { runAsync: getResearchScore, loading: getResearchScoreLoading } = useRequest(getResearchScoreApi, {
  // false 为自动执行
  manual: true,
})

const { runAsync: fileToPdf } = useRequest(fileToPdfReq, {
  manual: true
})

// 审核通过
const approveEvent = () => {
  showApprove.value = false
  ApprovalRef.value.checkSheetFormValidate((errors) => {
    if (!errors) {
      const fileIds = ApprovalRef.value && ApprovalRef.value.params && ApprovalRef.value.params['fileList'] ? ApprovalRef.value.params['fileList'].map((file: AttachmentFileInfoDTO) => {
        return file.id
      }) : undefined
      approveDetail({ id: route.query.id as string, status: props.moduleType === 'college' ? 2 : 5, description: ApprovalRef.value.params.description, fileIds: fileIds })
    }
  })
}

// 审核不通过
const disApproveEvent = () => {
  showDisApprove.value = false
  ApprovalRef.value.checkSheetFormValidate((errors) => {
    if (!errors) {
      const fileIds = ApprovalRef.value && ApprovalRef.value.params && ApprovalRef.value.params['fileList'] ? ApprovalRef.value.params['fileList'].map((file: AttachmentFileInfoDTO) => {
        return file.id
      }) : undefined
      approveDetail({ id: route.query.id as string, status: props.moduleType === 'college' ? 3 : 4, description: ApprovalRef.value.params.description, fileIds: fileIds })
    }
  })
}

// 编辑
const editForm = () => {
  // 修改参数
  const newQuery = {
    ...route.query,
    mode: 'edit'
  }
  router.replace({query: newQuery})
  sheetComponents.value.forEach((component: SheetInfoComponent) => {
    // 模块为我的成果，且mode=edit时，进入编辑模式，否则进入预览模式（没有详情id，说明是新建）
    if (component.config) {
      component.config.readonly = false
    } else {
      component.config = {}
      component.config.readonly = false
    }
    // 发明人
    if (component.key === 'accountName') {
      component.cValue = userStore.name
    }
    // 统计年度
    if (component.key === 'statisticalYear') {
      component.cValue = new Date().getFullYear()
    }
    if (component.type === 99 && component.config && component.config.list) {
      component.config.list.forEach((subComponent: SheetInfoComponent) => {
        if (subComponent.config) {
          subComponent.config.readonly = false
        } else {
          subComponent.config = {}
          subComponent.config.readonly = false
        }
      })
    }
  })
}

// 删除
const deleteForm = () => {
  showDeleteDetail.value = false
  deleteDetail({ id: route.query.id as string })
}

// 取消
const cancelForm = () => {
  showCancelSave.value = false
  if (!route.query.id) {
    closeCurrentTab()
  } else if (route.query.id && route.query.mode === 'edit') {
    // 修改参数
    const newQuery = {
      ...route.query,
      mode: 'preview'
    }
    router.replace({query: newQuery})
    sheetComponents.value.forEach((component: SheetInfoComponent) => {
      // 模块为我的成果，且mode=edit时，进入编辑模式，否则进入预览模式（没有详情id，说明是新建）
      if (component.config) {
        component.config.readonly = true
      } else {
        component.config = {}
        component.config.readonly = true
      }
      if (component.type === 99 && component.config && component.config.list) {
        component.config.list.forEach((subComponent: SheetInfoComponent) => {
          if (subComponent.config) {
            subComponent.config.readonly = true
          } else {
            subComponent.config = {}
            subComponent.config.readonly = true
          }
        })
      }
    })
  }
}

// 暂存
const tempSaveForm = () => {
  if (props.moduleType === 'mine') {
    if (route.query.id) {
      updateDetail(parameters.value)
    } else {
      createDetail(parameters.value)
    }
  } else {
    ResultsInfoRef.value.checkSheetFormValidate(async (errors) => {
      if (!errors) {
        updateDetail(parameters.value)
        cancelForm()
      } else {
        sheetComponents.value?.forEach((i) => {
          if (errors[0]?.reason?.[i?.key]) {
            ElMessage({
              message: errors[0]?.reason?.[i?.key]?.[0]?.message,
              type: 'error',
            })
          }
          if (i.type === 99 && i.config && i.config.list) {
            i.config.list.forEach((subComponent: SheetInfoComponent) => {
              if (errors[0]?.reason?.[subComponent?.key]) {
                ElMessage({
                  message: errors[0]?.reason?.[subComponent?.key]?.[0]?.message,
                  type: 'error',
                })
              }
            })
          }
        })
      }
    })
  }
}

// 科研分中金额是否必填
function requiredAmount() {
  // 金额和科研分组件的判定，type === 5 则手输科研分，否则根据typeReal === 2| 3 手输金额，1则自动带出分数不显示金额
  const researchScoreOption = appraiseStandardList.value.filter(item => item.id === ResultsInfoRef.value.params['methodCalculationId']).length > 0 ? appraiseStandardList.value.filter(item => item.id === ResultsInfoRef.value.params['methodCalculationId'])[0] : undefined
  if (researchScoreOption?.type === 5) {
    return false
  } else {
    if (researchScoreOption?.typeReal === 2 || researchScoreOption?.typeReal === 3) {
      return true
    } else {
      return false
    }
  }
}

// 科研分是否必填
function requiredResearchScore() {
  // 金额和科研分组件的判定，type === 5 则手输科研分，否则根据typeReal === 2| 3 手输金额，1则自动带出分数不显示金额
  const researchScoreOption = appraiseStandardList.value.filter(item => item.id === ResultsInfoRef.value.params['methodCalculationId']).length > 0 ? appraiseStandardList.value.filter(item => item.id === ResultsInfoRef.value.params['methodCalculationId'])[0] : undefined
  if (researchScoreOption?.type === 5) {
    return true
  } else {
    return false
  }
}

const submitAlertEvent = () => {
  ResultsInfoRef.value.checkSheetFormValidate(async (errors) => {
    if (!errors) {
      // 科研分特殊处理
      if (ResultsInfoRef.value.params['researchScoreFlag'] && ResultsInfoRef.value && !ResultsInfoRef.value.params['scoringCategoryId']) {
        ElMessage({
          message: '计分类别不能为空',
          type: 'error',
        })
      } else if (ResultsInfoRef.value.params['researchScoreFlag'] && ResultsInfoRef.value && !ResultsInfoRef.value.params['methodCalculationId']) {
        ElMessage({
          message: '量化指标不能为空',
          type: 'error',
        })
      } else if (ResultsInfoRef.value.params['researchScoreFlag'] && requiredAmount() && ResultsInfoRef.value && !ResultsInfoRef.value.params['amount']) {
        ElMessage({
          message: '金额不能为空',
          type: 'error',
        })
      } else if (ResultsInfoRef.value.params['researchScoreFlag'] && requiredResearchScore() && ResultsInfoRef.value && !ResultsInfoRef.value.params['researchScore']) {
        ElMessage({
          message: '科研分不能为空',
          type: 'error',
        })
      } else {
        showSubmitSave.value = true
      }
    } else {
      if (route.query.mode !== 'edit') {
        ResultsInfoRef.value.cancelSheetFormValidate()
      }
      sheetComponents.value?.forEach((i) => {
        if (errors[0]?.reason?.[i?.key]) {
          ElMessage({
            message: errors[0]?.reason?.[i?.key]?.[0]?.message,
            type: 'error',
          })
        }
        if (i.type === 99 && i.config && i.config.list) {
          i.config.list.forEach((subComponent: SheetInfoComponent) => {
            if (errors[0]?.reason?.[subComponent?.key]) {
              ElMessage({
                message: errors[0]?.reason?.[subComponent?.key]?.[0]?.message,
                type: 'error',
              })
            }
          })
        }
      })
    }
  })
}

// 提交
const submitForm = async () => {
  if (props.moduleType === 'mine') {
    showSubmitSave.value = false
    if ((status.value === 0 || status.value === 3 || status.value === 4) && route.query.id && route.query.mode !== 'edit') {
      // 提交
      approveDetail({ id: route.query.id as string, status: 1 })
    } else {
      if (route.query.id) {
        await updateDetail({...parameters.value, isSubmit: true})
        // 提交
        approveDetail({ id: route.query.id as string, status: 1 })
      } else {
        await createDetail({...parameters.value, isSubmit: true})
        // 提交
        approveDetail({ id: detailId.value as string, status: 1 })
      }
    }
  }
}

// 提取附属组件，用于预览模式下的表格显示
const getMixedComponents = (component: SheetInfoComponent) => {
  const mixedComponents = sheetComponents.value.filter(item => item.type === 99).filter(item => item.depended === component.key) as SheetInfoComponent[]
  if (mixedComponents.length > 0) {
    const mixedSubComponents = mixedComponents[0].config?.list?.filter(item => !!ResultsInfoRef.value.params[item.key])
    return  mixedSubComponents ?? []
  } else {
    return []
  }
}

// 添加 专利权人
const addPatenteeEvent = () => {
  showPatenteeAddBtn.value = false
}

// 保存 专利权人
const savePatenteeInput = () => {
  if (patenteeInput.value && patenteeInput.value.replace(/\s+/g, '').length > 0) {
    ResultsInfoRef.value.params['patentee'].push(patenteeInput.value)
  }
  patenteeInput.value = undefined
  showPatenteeAddBtn.value = true
}

// 移除 专利权人
const removePatenteeEvent = (index: number) => {
  ResultsInfoRef.value.params['patentee'].splice(index, 1)
}

watch(
  () => route.query.id,
  async () => {
    try {
      await getAppraiseStandardList({}) // 这里必须要先拿到量化考核指标，为了兼容已登记状态下，被移除的量化指标的正常显示。
    } catch (error) {
      appraiseStandardList.value = []
    }
    if (route.query.id) {
      getDetail({ id: route.query.id })
      getAuditLog({ logId: route.query.id as string })
    }
  }, {
    immediate: true
  }
)

watch(
  () => ResultsInfoRef.value && ResultsInfoRef.value.params,
  () => {
    if (ResultsInfoRef.value && ResultsInfoRef.value.params) {
      const params = ResultsInfoRef.value.params;
      // 遍历对象的每个键值对
      for (const key in params) {
        // 检查 key 是否是对象自身的属性（而不是从原型链继承的）
        if (params.hasOwnProperty(key)) {
          // 获取对应的值
          const value = params[key];
          // 检查值是否存在且不为空（这里的“不为空”定义可能因情况而异）
          // 例如，我们可能认为 null、undefined、空字符串、空数组等都是“空”的
          if (value !== null && value !== undefined && value !== '' && (typeof value !== 'object' || Object.keys(value).length > 0)) {
            // 如果值存在且不为空，取消必填校验提示
            ResultsInfoRef.value.cancelSheetFormValidate(key)
          }
        }
      }
      const researchScoreOption = appraiseStandardList.value.filter(item => item.id === ResultsInfoRef.value.params['methodCalculationId']).length > 0 ? appraiseStandardList.value.filter(item => item.id === ResultsInfoRef.value.params['methodCalculationId'])[0] : undefined
      sheetComponents.value.forEach((component: SheetInfoComponent) => {
        if (props.moduleType === 'mine' && (!route.query.id || route.query.id && route.query.mode === 'edit')) {
          if (component.key === 'accountName') {
            // 发明人
            ResultsInfoRef.value.params[component.key] = userStore.name
          }
          if (component.key === 'statisticalYear') {
            // 统计年度
            ResultsInfoRef.value.params[component.key] = new Date().getFullYear()
          }
        }
        // 科研分
        if (component.key === 'assessmentMethodId' && component.config && component.config.list) {
          component.config.list.forEach(async (subComponent: SheetInfoComponent) => {
            if (subComponent.key === 'methodCalculationId' && subComponent.config && subComponent.depended) {
              // 量化指标选项 name >> 算分使用id
              subComponent.config.options = appraiseStandardList.value.filter(item => item.typeId === ResultsInfoRef.value.params[subComponent.depended as string])
              if (subComponent.cValue !== ResultsInfoRef.value.params['methodCalculationId']) {
                // 计算并自动带出科研分
                const researchScore = await getResearchScore({ amount: ResultsInfoRef.value.params['amount'], methodCalculationId: ResultsInfoRef.value.params['methodCalculationId'] })
                ResultsInfoRef.value.params['researchScore'] = researchScoreOption && researchScoreOption.type !== 5 ? researchScore : undefined
              }
            }
            // 金额和科研分组件的判定，type === 5 则手输科研分，否则根据typeReal === 2| 3 手输金额，1则自动带出分数不显示金额
            if (researchScoreOption) {
              if (subComponent.key === 'amount') { // 金额 amount
                if (researchScoreOption.type === 5) {
                  subComponent.hidden = true
                } else {
                  if (researchScoreOption.typeReal === 2 || researchScoreOption.typeReal === 3) {
                    subComponent.type = -1
                    subComponent.hidden = false
                    if (subComponent.config && subComponent.config.rules.length > 0) {
                      subComponent.config.rules[0].required = true
                    }
                    // 计算并自动带出科研分
                    if (subComponent.cValue !== ResultsInfoRef.value.params['amount']) {
                      const researchScore = await getResearchScore({ amount: ResultsInfoRef.value.params['amount'], methodCalculationId: ResultsInfoRef.value.params['methodCalculationId'] })
                      ResultsInfoRef.value.params['researchScore'] = researchScoreOption && researchScoreOption.type !== 5 ? researchScore : undefined
                    }
                  } else {
                    subComponent.hidden = true
                    if (subComponent.config && subComponent.config.rules.length > 0) {
                      subComponent.config.rules[0].required = false
                    }
                  }
                  if (subComponent.config) {
                    subComponent.config.suffix = researchScoreOption.unitEnum === 1 ? '元' : '万元'
                    subComponent.config.precision = researchScoreOption.unitEnum === 1 ? 2 : 6
                  } else {
                    subComponent.config = {}
                    subComponent.config.suffix = researchScoreOption.unitEnum === 1 ? '元' : '万元'
                    subComponent.config.precision = researchScoreOption.unitEnum === 1 ? 2 : 6
                  }
                }
              }
              if (subComponent.key === 'researchScore') { // 科研分 researchScore
                if (researchScoreOption.type === 5) {
                  subComponent.type = -1
                  if (subComponent.config) {
                    subComponent.config.controls = false
                  } else {
                    subComponent.config = {}
                    subComponent.config.controls = false
                  }
                  if (subComponent.config && subComponent.config.rules.length > 0) {
                    subComponent.config.rules[0].required = true
                  }
                } else {
                  subComponent.type = 3
                  if (subComponent.config && subComponent.config.rules.length > 0) {
                    subComponent.config.rules[0].required = false
                  }
                }
              }
            }
          })
        }
        // 控制依赖组件的显隐
        if (component.depended === 'researchScoreFlag') {
          component.hidden = ResultsInfoRef.value.params[component.depended] && (!route.query.id || route.query.mode === 'edit') ? false : true
        }
        component.cValue = ResultsInfoRef.value.params[component.key]
        if (component.type === 99 && component.config && component.config.list) {
          component.config.list.forEach((subComponent: SheetInfoComponent) => {
            if (subComponent.key) {
              subComponent.cValue = ResultsInfoRef.value.params[subComponent.key]
            }
          })
        }
      })
    }
  }, {
    immediate: true,
    deep: true
  }
)

onMounted(() => {
  sheetComponents.value.forEach((component: SheetInfoComponent) => {
    // 模块为我的成果，且mode=edit时，进入编辑模式，否则进入预览模式（没有详情id，说明是新建）
    if (component.config) {
      component.config.readonly = props.moduleType === 'mine' ? ((route.query.mode !== 'edit' && route.query.id) ? true : false) : (route.query.mode !== 'edit' ? true : false)
    } else {
      component.config = {}
      component.config.readonly = props.moduleType === 'mine' ? ((route.query.mode !== 'edit' && route.query.id) ? true : false) : (route.query.mode !== 'edit' ? true : false)
    }
    if (component.type === 99 && component.config && component.config.list) {
      component.config.list.forEach((subComponent: SheetInfoComponent) => {
        if (subComponent.config) {
          subComponent.config.readonly = props.moduleType === 'mine' ? ((route.query.mode !== 'edit' && route.query.id) ? true : false) : (route.query.mode !== 'edit' ? true : false)
        } else {
          subComponent.config = {}
          subComponent.config.readonly = props.moduleType === 'mine' ? ((route.query.mode !== 'edit' && route.query.id) ? true : false) : (route.query.mode !== 'edit' ? true : false)
        }
      })
    }
  })
})
</script>

<template>
  <div>
    <StatusBar v-if="route.query.id" :status="status"/>
    <ApplicantInfo v-if="props.moduleType !== 'mine' && route.query.mode !== 'edit'" :first-content="departmentName" :second-content="applyCode" :third-content="applyName" />
    <x-sheet-info ref="ResultsInfoRef" :class="{ 'sheetInfoClass': route.query.id && route.query.mode !== 'edit' }" :fileToPdf="fileToPdf" :uploadFileUrl="uploadFileUrl" :components="sheetComponents" :singleRow="!route.query.id || route.query.mode === 'edit'" style="padding-left: 20px;padding-right: 20px;padding-bottom: 24px;">
      <template #researchScoreFlag="{component}">
        <div class="flex flex-col" style="margin: -12px;">
          <div class="researchScore" :style="{ borderBottom: ResultsInfoRef.params[component.key] ? '1px solid #BEDAFF' : 'none' }">
            {{ component.config.options.filter(radio => radio.value === ResultsInfoRef.params[component.key])[0].title }}
          </div>
          <div v-if="ResultsInfoRef.params[component.key]">
            <div v-for="(subComponent, index) in getMixedComponents(component)" :key="subComponent.key" class="researchScore" :style="{ borderBottom: index !== getMixedComponents(component).length - 1 ? '1px solid #BEDAFF' : 'none', color: subComponent.key === 'researchScore' ? '#F53F3F' : '#1D2129', fontWeight: subComponent.key === 'researchScore' ? 'bold' : 'normal' }">
              <span v-if="subComponent.type === 1 && subComponent.config && subComponent.config.options && subComponent.config.options.filter(option => option.value === ResultsInfoRef.params[subComponent.key]).length > 0">
                  {{ subComponent.config.options.filter(option => option.value === ResultsInfoRef.params[subComponent.key])[0].title }}
              </span>
              <span v-else>
                {{ ResultsInfoRef.params[subComponent.key] }}
              </span>
              {{ subComponent.config && subComponent.config.suffix ? subComponent.config.suffix : '' }}
            </div>
          </div>
        </div>
      </template>
      <template v-if="ResultsInfoRef" #patentee="{component}">
        <div class="patenteeStyle">
          <div class="patenteeItemStyle" v-for="(item, index) in ResultsInfoRef.params['patentee']" :key="index">
            {{ item }}
            <el-icon v-if="index !== 0 && !component.config.readonly" @click="removePatenteeEvent(index)"><Close /></el-icon>
            <span v-if="index !== ResultsInfoRef.params['patentee'].length - 1 && component.config.readonly">、</span>
          </div>
          <div v-if="showPatenteeAddBtn && !component.config.readonly" class="patenteeAdd">
            <el-tooltip content="最多可添加10个其他企业" :disabled="ResultsInfoRef.params['patentee'].length < 11">
              <el-button type="primary" :icon="Plus" :disabled="ResultsInfoRef.params['patentee'].length >= 11" @click="addPatenteeEvent">添加其他企业</el-button>
            </el-tooltip>
          </div>
          <div v-if="!showPatenteeAddBtn && !component.config.readonly" class="patenteeAdd">
            <el-input
              type="text"
              v-model="patenteeInput"
              :maxlength="50"
              :show-word-limit="true"
              placeholder="请输入"
            />
            <el-button @click="savePatenteeInput">保存</el-button>
          </div>
        </div>
      </template>
      <template #fileTip>
        <div style="color: #606266;font-size: 12px;line-height: 16px;">
          请上传大小不超过 <b style="color: #f56c6c">100MB</b> 格式为 <b style="color: #f56c6c">doc/docx/xls/xlsx/txt/pdf/png/jpg/jpeg</b>
          的文件，最多上传20个文件
        </div>
        <div class="specificRequirementRow">具体要求：授权/登记证书。</div>
      </template>
    </x-sheet-info>
    <div v-if="route.query.id && route.query.mode !== 'edit'" class="apply-record" style="padding-bottom: 24px;">
      <div class="area-title">审核记录</div>
      <x-table-form
        :data="dataList"
        :columns="columns"
        :auto-height="true"
        :tableLoading="logLoading"
      >
        <template #index="{rowIndex}">
          {{ rowIndex + 1 }}
        </template>
        <template #status="{record}">
          <div class="status-box">
            <div
              class="status-dot"
              :style="`background-color: ${AuditLogResultColorMap[record.status]}`"
            />
            <div
              class="status-text"
              :style="`color: ${AuditLogResultColorMap[record.status]}`"
            >
              {{ AuditLogResultMap[record.status] }}
            </div>
          </div>
        </template>
        <template #approve="{record}">
          <div v-if="record.description && record.description.length > 0">
            审核意见：
            <span style="white-space: wrap;">
              {{ record.description }}
            </span>
          </div>
          <div v-if="record.attachmentFileInfoDTOList && record.attachmentFileInfoDTOList.length > 0">
            相关附件：
            <span v-for="attachment in record.attachmentFileInfoDTOList" :key="attachment.id">
              <FilePreviewItem :file="attachment"/>
            </span>
          </div>
        </template>
      </x-table-form>
    </div>
    <div v-if="((props.moduleType === 'college' && status === 1) || (props.moduleType === 'office' && status === 2)) && route.query.mode !== 'edit'" class="apply-record">
      <x-sheet-info
        ref="ApprovalRef"
        class="approvalSheetClass"
        :fileToPdf="fileToPdf"
        :uploadFileUrl="uploadFileUrl"
        :components="approvalComponents"
        section-title="审核意见"
        style="padding-bottom: 32px;"/>
    </div>
    <div v-if="(props.moduleType === 'college' && status === 1) || (props.moduleType === 'office' && status === 2)" class="examine-bar-admin">
      <el-button v-if="route.query.mode !== 'edit'" type="primary" @click="editForm">编辑</el-button>
      <el-button v-if="route.query.mode === 'edit'" @click="() => showCancelSave = true">取消</el-button>
      <el-button v-if="route.query.mode === 'edit'" @click="tempSaveForm">保存</el-button>
      <el-button v-if="route.query.mode !== 'edit'" type="danger" @click="() => showDisApprove = true">审核不通过</el-button>
      <el-button v-if="route.query.mode !== 'edit'" type="primary" @click="() => showApprove = true">审核通过</el-button>
    </div>
    <div v-if="props.moduleType === 'mine' && !route.query.readonly && status !== 1 && status !== 2" class="examine-bar">
      <el-button v-if="(status === 0 || status === 3 || status === 4) && route.query.id && route.query.mode !== 'edit'" type="danger" @click="() => showDeleteDetail = true">删除</el-button>
      <el-button v-if="(status === 0 || status === 3 || status === 4) && route.query.id && route.query.mode !== 'edit'" type="primary" @click="editForm">编辑</el-button>
      <el-button v-if="!route.query.id || (route.query.id && route.query.mode === 'edit')" @click="() => showCancelSave = true">取消</el-button>
      <el-button v-if="!route.query.id || (route.query.id && route.query.mode === 'edit')" @click="tempSaveForm">暂存</el-button>
      <el-button v-if="!route.query.id || (route.query.id && status === 0)" type="primary" @click="submitAlertEvent">提交</el-button>
    </div>
    <DelConfirmModal v-if="showDeleteDetail" :visible="showDeleteDetail" text="是否确认删除？" ok-text="删除" @cancel="() => { showDeleteDetail = false }" @ok="deleteForm" />
    <DelConfirmModal v-if="showCancelSave" :visible="showCancelSave" text="是否确认取消保存？" ok-text="确定" @cancel="() => { showCancelSave = false }" @ok="cancelForm" />
    <DelConfirmModal v-if="showSubmitSave" :visible="showSubmitSave" text="是否确认提交？" ok-text="确定" @cancel="() => { showSubmitSave = false }" @ok="submitForm" />
    <DelConfirmModal v-if="showDisApprove" :visible="showDisApprove" text="是否确认审核不通过？" ok-text="审核不通过" @cancel="() => { showDisApprove = false }" @ok="disApproveEvent" />
    <DelConfirmModal v-if="showApprove" :visible="showApprove" text="是否确认审核通过？" ok-text="审核通过" @cancel="() => { showApprove = false }" @ok="approveEvent" />
    <div v-if="(props.moduleType === 'mine' && !route.query.readonly && status !== 1 && status !== 2) || (props.moduleType === 'college' && status === 1) || (props.moduleType === 'office' && status === 2)" class="h-[72px] bg-white"></div>
  </div>
</template>

<style scoped lang="scss">
.sheetInfoClass {
  .researchScore {
    padding: 12px;
    min-height: 46px;
  }
  :deep(.multiRowsClass) {
    border: 1px solid #BEDAFF;
    border-left: none;
    border-top: none;
  }
  :deep(.el-form) {
    border-left: 1px solid #BEDAFF;
    border-top: 1px solid #BEDAFF;
  }
  :deep(.el-form .el-form-item__label) {
    background-color: #F6FAFF;
    border-right: 1px solid #BEDAFF;
  }
  :deep(.el-form-item__content) {
    padding: 12px;
    min-height: 46px;
  }
  // 预览时，去除必填星号
  :deep(.el-form-item__label:before) {
    display: none;
  }
}
.approvalSheetClass {
  :deep(.area-title) {
    margin-top: 0px;
  }
}
.specificRequirementRow {
  font-size: 12px;
  line-height: 16px;
  color: #86909C;
}
.patenteeStyle {
  display: flex;
  flex-wrap: wrap;
  .patenteeItemStyle {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 8px;
    :deep(.el-icon) {
      margin-left: 4px;
      margin-right: 4px;
      width: 20px;
      height: 20px;
      border-radius: 50%;
      background-color: #F2F3F5;
      color: #4E5969;
    }
  } 
}
.patenteeAdd {
  display: flex;
  flex-direction: row;
  gap: 8px;
}

.apply-record {
  display: flex;
  flex-direction: column;
  height: auto;
  background-color: white;
  padding-left: 20px;
  padding-right: 20px;
  .area-title {
    height: 20px;
    font-weight: bold;
    color: #1D2129;
    font-size: 14px;
    margin-bottom: 16px;
  }
  .status-box {
    display: flex;
    align-items: center;
    flex-direction: row;
    .status-dot {
      width: 6px;
      height: 6px;
      border-radius: 3px;
      margin-right: 8px;
    }
    .status-text {
      width: calc(100% - 14px);
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
}

.examine-bar {
  border-top: 1px solid #E5E6EB;
  --at-apply: fixed bottom-0 left-0 right-0 h-[72px] flex items-center justify-center bg-white z-1999;

  :deep(.el-button) {
    height: 32px;
  }
}
.examine-bar-admin {
  border-top: 1px solid #E5E6EB;
  --at-apply: fixed bottom-0 left-0 right-0 h-[72px] flex items-center justify-center bg-white z-1999;

  :deep(.el-button) {
    height: 32px;
  }
  // type：danger样式
  :deep(.el-button--danger) {
    background-color: #FFECE8;
    border: none;
    color: #F53F3F;
    font-size: 14px;
    font-weight: normal;
  }
  :deep(.el-button--danger:hover) {
    background-color: #FDCDC5;
  }
}
</style>